<template>
	<view>
		<view class="flex items-center justify-between mb-20">
			<view class="flex items-center">
				<ImageBoxVue src="/static/icons/title.png" width="35rpx" height="29rpx"></ImageBoxVue>
				<text class="text-sm font-bold ml-10">我的教学</text>
			</view>
			<view class="">
				<text>红钻服务</text>
				<switch style="transform:scale(0.8)" class="ml-10" :checked="anchor.redser == 1"  @change="switchChange" />
			</view>
		</view>
		<!-- <view class="flex justify-between">
			<view class="h-120 rounded-lg bg-contain flex items-center justify-center" v-for="e,i in teachingList" :key="i" @click="onPath(e.router)"
				:style="{backgroundImage:`url(${e.bg})`}" style="width:calc(33.33% - 13rpx)">
				<text class="text-sm">{{e.label}}</text>
			</view>
		</view> -->
	</view>
</template>

<script setup>
	import userApi from '@/apis/apiList/userApi';
	
	const {
		anchor
	} = defineProps(['anchor'])
	const teachingList = [{
		bg: "/static/user/solve.png",
		label: "待解问题",
		router: "/pages/user/toBeSolved"
	}, {
		bg: "/static/user/post.png",
		label: "贴吧答题",
		router: "/pages/user/tieBaProblem"
	}, {
		bg: "/static/user/answer.png",
		label: "抢答问题",
		router: ""
	}]
	const switchChange = (e) => {
		const opt = {
			id: uni.getStorageSync('anchor').id,
			redser: e.detail.value?0:1
		}
		userApi.anchorSetRedDimService(opt).then(res =>{
			userApi.queryAnchorInfoByid({
				"id": uni.getStorageSync('anchor').id
			}).then(res => {
				anchor.value = res.data
				uni.setStorageSync('anchor', res.data)
			})
		})
	}
	const onPath = (router) => {
		console.log(router)
		uni.navigateTo({
			url: router,
		});
	}
</script>

<style>
</style>